package iconSwingStates.Transitions.TransitionOnTag;

import iconSwingStates.Transitions.TPosition;
import fr.lri.swingstates.canvas.CShape;



/**
 * TMoveOnTag is the transition symbolising every transition made over a tag.
 * @author uribe-gaget
 *
 */
public class TMoveOnTag extends TPosition {
	/**
	 * The tag the transition will look after
	 */
	private String tag;
	/**
	 * The shape that "fired" the transition
	 */
	private CShape shape = null;

	/**
	 * Constructor when no slots are needed and when the output state is the same as the input state.
	 * @param name Name of the transition
	 * @param pointer The pointer used to get the positions
	 * @param tag The tag
	 */
	public TMoveOnTag(String name, String pointer, String tag) {
		super(name,pointer);
		this.tag = tag;
	}
	
	/**
	 * Constructor when no slots are needed and when the output state is different from the input state.
	 * @param name Name of the transition
	 * @param pointer The pointer used to get the positions
	 * @param tag The tag
	 * @param output The output state
	 */
	public TMoveOnTag(String name, String pointer, String tag, String output) {
		super(name, pointer, output);
		this.tag = tag;
	}


	
	/**
	 * Constructor when one slot is needed and when the output state is the same as the input state.
	 * @param name Name of the transition
	 * @param pointer The pointer used to get the positions
	 * @param type Type of the slot
	 * @param obligatory If the slot must be connected or not
	 * @param tag The tag
	 */
	
	public TMoveOnTag(String name, String pointer, int type,boolean obligatory, String tag) {
		super(name,pointer,type, obligatory);
		this.tag = tag;
	}

	/**
	 * Constructor when one slot is needed and when the output state is different from the input state.
	 * @param name Name of the transition
	 * @param pointer The pointer used to get the positions
	 * @param type Type of the slot
	 * @param obligatory If the slot must be connected or not
	 * @param tag The tag
	 * @param output The output state
	 */
	public TMoveOnTag(String name, String pointer, int type,boolean obligatory, String tag, String output) {
		super(name, pointer, type,obligatory, output);
		this.tag = tag;
	}



	/**
	 * Constructor when more than one slot is needed and when the output state is the same as the input state.
	 * @param name Name of the transition
	 * @param pointer The pointer used to get the positions
	 * @param type Types of the slots
	 * @param obligatory If the slot must be connected or not
	 * @param tag The tag
	 */
	public TMoveOnTag(String name, String pointer, int[] type,boolean obligatory, boolean synchro,String tag) {
		super(name,pointer,type, obligatory,synchro);
		this.tag = tag;
	}

	/**
	 * Constructor when more than one slot is needed and when the output state is different from the input state.
	 * @param name Name of the transition
	 * @param pointer The pointer used to get the positions
	 * @param type Types of the slots
	 * @param obligatory If the slot must be connected or not
	 * @param tag The tag
	 * @param output The output state
	 */
	public TMoveOnTag(String name, String pointer, int[] type,boolean obligatory,boolean synchro, String tag, String output) {
		super(name, pointer, type,obligatory,synchro, output);
		this.tag = tag;
	}

	/**
	 * Return the string representating the tag of the transition
	 * @return the tag
	 */
	public String getTag(){
		return tag;
	}

	/**
	 * Specify the shape which the transition was fired about
	 * @param s The shape
	 */
	public void setShape(CShape s){
		shape = s;
	}

	/**
	 * Return the shape having the tag
	 * @return the shape
	 */
	public CShape getShape(){
		return shape;
	}

	@Override
	public boolean equals(Object obj) {
		if(obj instanceof TMoveOnTag){
			TMoveOnTag tr = (TMoveOnTag)obj;
			if(tr.getName().compareTo(this.getName()) == 0 && getInputState().getName().compareTo(tr.getInputState().getName()) == 0 && tag.equals(tr.getTag())){
				return true;
			}

		}
		return false;
	}

}